<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-7-21
 * Func   银行卡管理
 */
defined('IN_YuLin') || exit('NO PERMIT!');
$seo['title'] = '大众彩票-银行卡管理';
$pageTitle    = '银行卡管理';
$navTag       = 'member';
$page         = 'member/bankcard';

UserLogin();
$userInfo     = $_user;
// 载入用户基本信息
// 获取用户当前绑定的银行卡
$bindBankTab   = Table('user_bank');
$bankCateTab   = Table('web_bank');
$bankCateSql   = 'SELECT id, name, tags FROM ' . $bankCateTab . ' WHERE status = 1';
$bankCateList  = $db->getall($bankCateSql);
$bankCateIdKey = array();
if ($bankCateList){
    foreach ($bankCateList as $bk => $bv){
        $bankCateIdKey[$bv['id']] = $bv;
    }
}
$userBindSql   = 'SELECT id, truename, bank, bankcard, province, city FROM ' . $bindBankTab . ' WHERE status = 1 AND uid = ' . $_uid;
$userBindList  = $db->getall($userBindSql);
if ($userBindList){
    foreach ($userBindList as $k => $v){
        $userBindList[$k]['rebankcard'] = '************' . substr($v['bankcard'], -4);
        $retruename = '';
        for($i = 1; $i <= mb_strlen($v['truename']); $i++){
            if($i < mb_strlen($v['truename'])){
                $retruename .= '*';
            }
        }
        $retruename .= mb_substr($v['truename'], -1);
        $userBindList[$k]['retruename'] = $retruename;
    }
}
$tpl->display($page);